<?php

namespace App\Models\Experience;
use App\Libs\Helper\CommonHelper;

class ExpOrder extends \App\Libs\Base\BaseModel
{
    protected $numPerPage = 10;
    protected $__TABLE__ = 't_paile_experience_order';

    /**
     *    跳过检测了
     */
    public function beforeValidation()
    {
        self::skipValidation(['type'], $this);
    }

    /**
     * @param $expId 数组：体验表id
     * @param $column  返回数组的键名称
     * @return mixed
     */
    public static function getAppliesOfGoods($expId, $column)
    {
        $haveApplyCount = ExpOrder::findAll([
            'conditions' => 'eid IN ({orderId:array})',
            'columns' => 'id,eid,count(id) as count',
            'bind' => ['orderId' => $expId],
            'group' => 'eid'
        ])->toArray();
        if(!empty($haveApplyCount)){
            $haveApplyData = CommonHelper::setColToKey($haveApplyCount, $column);
        }else{
           $haveApplyData = [];
        }
        return $haveApplyData;
    }


}